#include <myheader.h>

/*Usage: 使用目录流打印目录下的所有文件 变量：path */
int main(int argc, char *argv[])
{
    ARGC_CHECK(argc,2);
    //打开目录流
    DIR* dir_p;
    dir_p = opendir(argv[1]);
    ERROR_CHECK(dir_p ,NULL, "OPENDIR");

    struct dirent *dirent_struct;
    //定义direntstruct
    
    while((dirent_struct = readdir(dir_p))!=NULL){
        printf("inode : %lu, d_name : %s, d_off :"
               "%ld, d_reclen: %hu, d_type : %u\n",
    dirent_struct->d_ino,
    dirent_struct->d_name,
    dirent_struct->d_off,
    dirent_struct->d_reclen,
    dirent_struct->d_type );
    }
    rewinddir(dir_p);
    dirent_struct = readdir(dir_p);
    printf("inode : %lu, d_name : %s, d_off :"
          "%ld, d_reclen: %hu, d_type : %u\n",
    dirent_struct->d_ino,
    dirent_struct->d_name,
    dirent_struct->d_off,
    dirent_struct->d_reclen,
    dirent_struct->d_type );
    
    closedir(dir_p);
    return 0;
    }

